#ifndef __VOCABULARY_TREE_H__
#define __VOCABULARY_TREE_H__

#include "headers.h"
#include "hierarchical k-means.h"

using namespace cv;


    
class VTreeMatcher
{
public:
	VTreeMatcher(int _depth,int _branch);
	~VTreeMatcher();
	void addDescriptor(const cv::Mat &train);
	void train();
	void clear();
	int match(const cv::Mat &Descriptor, int n, vector<int> &matches);
	cv::Mat getTrainDescriptor(int n);
private:
	cv::Mat computeImgDesp(const cv::Mat &desp);
	void feature2word(const cv::Mat &desp, vector<int> &words);
	int matchImgDescritpors(const cv::Mat &imgDescriptor, int n, vector<int> &matches);
	cv::Ptr<hierarchical_kmeans> hkmeans;
	vector<cv::Mat> trainDesps;
	vector<cv::Mat> vocabulary;
	vector<float> idfs;
	vector<cv::Mat> trainImgDesps;
	int depth;
	int branch;
	int clusterCount;
};

















#endif